<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>在线客服</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  	<style type="text/css">
  		*{margin: 0px;padding: 0px;left: 0px;top: 0px;}
  		.div{height: 350px;width: 460px;}
  		.div div{border:groove;}
  		.divtop{height: 280px;overflow-y:scroll; }
  		.divdow{height: 20%;margin-top: -4px;}
  	</style>
  	<script src="<%=basePath%>js/jquery.js"></script>
  </head>
  <body>
  <table>
  	<tbody><tr><td>
  <div class="div">
   	<div id="message" class="divtop">
   	</div>
   	<div class="divdow">
   		<span>
   		<textarea id="rcontext" rows="2" cols="46"></textarea>
   		<button onclick="sub()" style="height: 25px">&nbsp;回答&nbsp;</button>
   		<input type="text" id="user" name="user" value="${user }"/>
   		</span>
   		<script type="text/javascript">
   		function sub(){
   			var rcontext = $("#rcontext").val();
   			var sname = $("#sname").val();
   			var user = $("#user").val();
   			if(rcontext != ""){
  				$.post("<%=basePath%>chat_question.action",{sname:sname,replyMessage:rcontext,user:user},function(d){
  					$("#message").html(d);
  				});
  			}
  		}
  		function showMessage(){
  			var user = $("#user").val();
		  		$.post("<%=basePath%>chat_reqUser.action",{user:user}, function(html){
				    $("#message").html(html);
			  }); 
  		}
  		setInterval("showMessage()",10000);
   		</script>
   	</div>
   </div>
  		</td>
  			<td>
				当前客服<br/>
				<input type="hidden" name="sid"/>
				<input type="hidden" id="sname" value="${server.sname }"/>
				  	id:	${server.sid }<br/>
				  	name:${server.sname}
  			</td>
  		</tr>
  	</tbody>
   </table>
  </body>
</html>
